#include "common.h"
#include "property.h"

///////////////////////////////////////////////////////////////////////////////////

Property::Property ( EPropType propType, void * value, IValueSetter * valueSetter )
: propType    ( propType    )
, value       ( value       )
, valueSetter ( valueSetter )
{}

Property::~Property ()
{}

void Property::setProperty ( void * newValue )
{
    valueSetter -> setValue ( this -> value, newValue ); 
}

void * Property::getProperty ()
{
    return value;
}

///////////////////////////////////////////////////////////////////////////////////

EVarType GetVariableType ( EPropType propType )
{
    switch ( propType )
    {
    case e_Label:
        return stringType;
	case e_Type:
	case e_ObjectID:
		return intType;
    default:
        assert( 0 );
    }
    return (EVarType) -1;
}

void PropertyList::getPropertyTypeList ( std::vector<EPropType> & list )
{
    list.clear();
    list.resize ( propList.size ());
    std::vector<Property>::iterator it;
    int i = 0;
    for ( it = propList.begin(); it != propList.end(); ++it )
    {
        list[i] = it -> getPropType ();
        ++i;
    }
}

using std::string;

MAKE_CHECK_TYPE ( int    )
MAKE_CHECK_TYPE ( double )
MAKE_CHECK_TYPE ( string )

ObjectPropTypeAssociation objectPropTypeAssociation;